/**
 * Created by LeungZ on 2016/8/10.
 */

class Detail {
    constructor(detail, $stateParams) {
        "ngInject";
        this.k8sCode = $stateParams.kDbCode;
        this.name = $stateParams.name;
        this.namesp = $stateParams.namesp;
        this.appId = $stateParams.appId;

        if (detail) {
            this.selector = this.mapToArray(detail.selector);
            this.labels = this.mapToArray(detail.objectMeta.labels);
            this.strategy = detail.strategy;
            this.status = detail.statusInfo;
            this.newRs = detail.newReplicaSet;
            this.oldTable = detail.oldReplicaSetList.replicaSets;
        }
    }

    mapToArray(map) {
        let array = [];
        angular.forEach(Object.keys(map), function (ele) {
            array.push(ele + '=' + map[ele]);
        });
        return array;
    }
}
export default Detail